```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Elasticsearch 查询 DSL 深入解析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .code-block {
            background-color: #2d2d2d;
            color: #f8f8f2;
            border-radius: 6px;
            position: relative;
        }
        .code-block::before {
            content: 'JSON';
            position: absolute;
            top: 8px;
            right: 12px;
            color: rgba(255,255,255,0.5);
            font-size: 0.8rem;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0,0,0,0.1);
        }
        .link-hover {
            transition: all 0.3s ease;
        }
        .link-hover:hover {
            color: #667eea;
            transform: translateX(3px);
        }
        .highlight {
            position: relative;
            z-index: 1;
        }
        .highlight::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(102, 126, 234, 0.2);
            z-index: -1;
            transition: all 0.3s ease;
        }
        .highlight:hover::after {
            height: 100%;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col items-center text-center">
                <div class="mb-4">
                    <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-sm font-medium">技术指南</span>
                </div>
                <h1 class="text-4xl md:text-5xl font-bold mb-6 leading-tight">Elasticsearch 查询 DSL 深度解析</h1>
                <p class="text-xl md:text-2xl max-w-3xl opacity-90 mb-8">探索 JSON 结构化的强大查询语言，解锁 Elasticsearch 的完整潜力</p>
                <div class="flex space-x-4">
                    <a href="#intro" class="px-6 py-3 bg-white text-indigo-700 rounded-lg font-medium hover:bg-opacity-90 transition duration-300">
                        <i class="fas fa-search mr-2"></i>开始探索
                    </a>
                    <a href="#examples" class="px-6 py-3 border border-white border-opacity-30 rounded-lg hover:bg-white hover:bg-opacity-10 transition duration-300">
                        <i class="fas fa-code mr-2"></i>查看示例
                    </a>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 md:px-0 py-16">
        <!-- Introduction -->
        <section id="intro" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="h-px bg-gray-200 flex-1 mr-4"></div>
                <h2 class="text-2xl font-semibold text-gray-500">核心概念</h2>
                <div class="h-px bg-gray-200 flex-1 ml-4"></div>
            </div>
            <div class="prose max-w-none">
                <p class="text-lg mb-6">
                    Elasticsearch 的查询 DSL（Domain Specific Language）是一种基于 JSON 格式的专用查询语言，它允许用户以结构化的方式编写复杂的查询请求，从而在索引中搜索和分析文档。作为 Elasticsearch 的核心特性之一，查询 DSL 以灵活性和功能性为设计目标，支持各种类型的查询操作。
                </p>
                
                <div class="grid md:grid-cols-2 gap-8 mt-10">
                    <div class="bg-white p-6 rounded-xl shadow-md card-hover transition duration-300">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mr-4">
                                <i class="fas fa-search"></i>
                            </div>
                            <h3 class="text-xl font-semibold">查询（Query）</h3>
                        </div>
                        <p class="text-gray-600">用于检索符合条件的文档，并根据文档的相关性（relevance）对结果进行排序。通常用于全文搜索场景，例如匹配某个关键词或短语。</p>
                    </div>
                    <div class="bg-white p-6 rounded-xl shadow-md card-hover transition duration-300">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 rounded-full bg-purple-100 text-purple-600 flex items-center justify-center mr-4">
                                <i class="fas fa-filter"></i>
                            </div>
                            <h3 class="text-xl font-semibold">过滤器（Filter）</h3>
                        </div>
                        <p class="text-gray-600">用于检索符合条件的文档，但不计算相关性分数（score），因此性能更高。通常用于结构化查询或布尔逻辑查询。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Basic Structure -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-6 leading-tight highlight w-max">1. 查询 DSL 的基本结构</h2>
            <div class="prose max-w-none">
                <p class="mb-6">
                    Elasticsearch 的查询 DSL 基于 JSON 语法，主要分为查询（Query）和过滤器（Filter）两种类型。下面的示例展示了一个典型的复合查询结构：
                </p>
                
                <div class="code-block p-4 mb-8 overflow-x-auto">
                    <pre><code>{
  "query": {
    "bool": {
      "must": [
        { "match": { "title": "Elasticsearch" }},
        { "range": { "publish_date": { "gte": "2022-01-01" }}}
      ],
      "filter": [
        { "term": { "status": "published" }},
        { "term": { "category": "search engine" }}
      ]
    }
  }
}</code></pre>
                </div>
                
                <div class="bg-blue-50 border-l-4 border-blue-400 p-4 mb-8">
                    <div class="flex">
                        <div class="flex-shrink-0 text-blue-400">
                            <i class="fas fa-info-circle"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-blue-700">
                                <strong>关键点：</strong> 在复合查询中，<code class="bg-blue-100 px-1 rounded">must</code> 部分指定必须匹配的查询条件，而 <code class="bg-blue-100 px-1 rounded">filter</code> 部分指定需要应用的过滤条件。
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Advantages -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 leading-tight highlight w-max">2. 查询 DSL 的优势</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-indigo-100 text-indigo-600 flex items-center justify-center mr-4">
                            <i class="fas fa-bolt text-xl"></i>
                        </div>
                        <h3 class="text-xl font-semibold">灵活性和丰富的表达能力</h3>
                    </div>
                    <p class="text-gray-600 mb-4">查询 DSL 提供了广泛的查询类型，几乎涵盖了所有可能的查询需求，包括全文查询、术语查询、复合查询和聚合查询。</p>
                    <ul class="space-y-2 text-gray-600">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                            <span>支持复杂的布尔逻辑和评分规则</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                            <span>精确控制查询结果</span>
                        </li>
                    </ul>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-green-100 text-green-600 flex items-center justify-center mr-4">
                            <i class="fas fa-tachometer-alt text-xl"></i>
                        </div>
                        <h3 class="text-xl font-semibold">高效的查询性能</h3>
                    </div>
                    <p class="text-gray-600 mb-4">Elasticsearch 的查询 DSL 结合了查询和过滤器的概念，优化查询性能。过滤器不计算相关性得分，处理大量数据时非常高效。</p>
                    <ul class="space-y-2 text-gray-600">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>自动缓存常用过滤条件</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>智能查询优化引擎</span>
                        </li>
                    </ul>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-amber-100 text-amber-600 flex items-center justify-center mr-4">
                            <i class="fas fa-file-code text-xl"></i>
                        </div>
                        <h3 class="text-xl font-semibold">直观的 JSON 格式</h3>
                    </div>
                    <p class="text-gray-600 mb-4">查询 DSL 使用 JSON 格式，非常直观和易于理解。查询语句与返回结果保持一致性，易于阅读和编写。</p>
                    <ul class="space-y-2 text-gray-600">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-amber-500 mt-1 mr-2"></i>
                            <span>轻松嵌套多个查询条件</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-amber-500 mt-1 mr-2"></i>
                            <span>快速修改和调试查询</span>
                        </li>
                    </ul>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-center mb-4">
                        <div class="w-12 h-12 rounded-lg bg-purple-100 text-purple-600 flex items-center justify-center mr-4">
                            <i class="fas fa-chart-bar text-xl"></i>
                        </div>
                        <h3 class="text-xl font-semibold">支持丰富的分析功能</h3>
                    </div>
                    <p class="text-gray-600 mb-4">通过聚合框架，可以执行各种统计分析、时间序列分析、地理空间分析等操作。支持多层次嵌套聚合。</p>
                    <ul class="space-y-2 text-gray-600">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
                            <span>一次查询获得多种分析结果</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
                            <span>提高数据分析效率</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>

        <!-- Query Examples -->
        <section id="examples" class="mb-20">
            <h2 class="text-3xl font-bold mb-8 leading-tight highlight w-max">3. 常见查询类型和示例</h2>
            
            <div class="space-y-12">
                <div class="bg-white rounded-xl overflow-hidden shadow-md">
                    <div class="md:flex">
                        <div class="md:w-1/3 bg-indigo-50 p-6 flex items-center">
                            <div>
                                <div class="flex items-center mb-4">
                                    <div class="w-10 h-10 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mr-4">
                                        <i class="fas fa-search"></i>
                                    </div>
                                    <h3 class="text-xl font-semibold">Match 查询</h3>
                                </div>
                                <p class="text-gray-600">最常用的全文查询类型之一，用于搜索文本字段中的一个或多个词。支持各种匹配模式。</p>
                            </div>
                        </div>
                        <div class="md:w-2/3 code-block p-6">
                            <pre><code>{
  "query": {
    "match": {
      "description": "Elasticsearch tutorial"
    }
  }
}</code></pre>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl overflow-hidden shadow-md">
                    <div class="md:flex">
                        <div class="md:w-1/3 bg-purple-50 p-6 flex items-center">
                            <div>
                                <div class="flex items-center mb-4">
                                    <div class="w-10 h-10 rounded-full bg-purple-100 text-purple-600 flex items-center justify-center mr-4">
                                        <i class="fas fa-search-minus"></i>
                                    </div>
                                    <h3 class="text-xl font-semibold">Term 查询</h3>
                                </div>
                                <p class="text-gray-600">用于精确匹配一个字段的值，通常用于结构化数据的查询。</p>
                            </div>
                        </div>
                        <div class="md:w-2/3 code-block p-6">
                            <pre><code>{
  "query": {
    "term": {
      "status": "active"
    }
  }
}</code></pre>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl overflow-hidden shadow-md">
                    <div class="md:flex">
                        <div class="md:w-1/3 bg-blue-50 p-6 flex items-center">
                            <div>
                                <div class="flex items-center mb-4">
                                    <div class="w-10 h-10 rounded-full bg-blue-100 text-blue-600 flex items-center justify-center mr-4">
                                        <i class="fas fa-random"></i>
                                    </div>
                                    <h3 class="text-xl font-semibold">Bool 查询</h3>
                                </div>
                                <p class="text-gray-600">复合查询类型，允许组合多个查询条件。支持must、should、must_not和filter等关键字。</p>
                            </div>
                        </div>
                        <div class="md:w-2/3 code-block p-6">
                            <pre><code>{
  "query": {
    "bool": {
      "must": [
        { "match": { "title": "Elasticsearch" }}
      ],
      "filter": [
        { "term": { "status": "published" }}
      ]
    }
  }
}</code></pre>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl overflow-hidden shadow-md">
                    <div class="md:flex">
                        <div class="md:w-1/3 bg-green-50 p-6 flex items-center">
                            <div>
                                <div class="flex items-center mb-4">
                                    <div class="w-10 h-10 rounded-full bg-green-100 text-green-600 flex items-center justify-center mr-4">
                                        <i class="fas fa-sliders-h"></i>
                                    </div>
                                    <h3 class="text-xl font-semibold">Range 查询</h3>
                                </div>
                                <p class="text-gray-600">用于匹配数值、日期或字符串字段的一个范围。</p>
                            </div>
                        </div>
                        <div class="md:w-2/3 code-block p-6">
                            <pre><code>{
  "query": {
    "range": {
      "publish_date": {
        "gte": "2022-01-01",
        "lte": "2022-12-31"
      }
    }
  }
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 leading-tight highlight w-max">查询 DSL 类型关系图</h2>
            <div class="bg-white p-6 rounded-xl shadow-md">
                <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
                <div class="mermaid">
                    graph TD
                        A[Elasticsearch 查询 DSL] --> B[查询 Query]
                        A --> C[过滤器 Filter]
                        
                        B --> D[全文查询]
                        B --> E[术语查询]
                        B --> F[复合查询]
                        B --> G[地理查询]
                        B --> H[特殊查询]
                        
                        D --> D1[Match]
                        D --> D2[Match Phrase]
                        D --> D3[Multi Match]
                        D --> D4[Query String]
                        
                        E --> E1[Term]
                        E --> E2[Terms]
                        E --> E3[Range]
                        E --> E4[Exists]
                        E --> E5[Prefix]
                        E --> E6[Wildcard]
                        E --> E7[Regexp]
                        E --> E8[Fuzzy]
                        
                        F --> F1[Bool]
                        F --> F2[Boosting]
                        F --> F3[Constant Score]
                        F --> F4[Dis Max]
                        F --> F5[Function Score]
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12">
        <div class="container mx-auto max-w-5xl px-4 md:px-0">
            <div class="flex flex-col items-center">
                <div class="mb-4">
                    <a href="http://www.yuque.com/jtostring" class="text-white text-xl font-medium hover:text-indigo-400 transition duration-300">
                        技术小馆
                    </a>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fas fa-external-link-alt mr-2"></i>http://www.yuque.com/jtostring
                    </a>
                </div>
                <div class="mt-6 flex space-x-6">
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-github text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-twitter text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-linkedin text-xl"></i>
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```